<?php

namespace App\Http\Requests\Customers\Address;

use App\Http\Requests\ApiRequest;
use App\Models\Customers\Customer;
use App\Models\Order\Address;

/**
 * @property string country_id - 国家
 * @property string zone_id - 省份
 * @property string city_id - 城市
 * @property string county_id - 区
 * @property string is_default
 *
 * @mixin ApiRequest
 */
trait AddressRule
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'fullname'     => 'required|string|max:' . Address::FULL_NAME_VARCHAR_LEN,
            'telephone'    => 'required|string|max:' . Address::TEL_PHONE_VARCHAR_LEN,
            'postcode'     => 'sometimes|required|string|max:' . Address::POSTCODE_VARCHAR_LEN, // todo 小胡  有值的时候验证，数据库设置默认值为empty string
            'address_1'    => 'required|string|max:' . Address::ADDRESS_VARCHAR_LEN,
            'company'      => 'nullable|string|max:' . Address::COMPANY_VARCHAR_LEN,

            'country_id'   => 'required|int|min:1|max:' . self::MAX_INT,
            'zone_id'      => 'required|int|min:1|max:' . self::MAX_INT,
            'city_id'      => 'required|int|min:1|max:' . self::MAX_INT,
            'county_id'    => 'required|int|min:1|max:' . self::MAX_INT,

            'is_default'   => 'required|boolean',

//            'address_2'    => 'nullable|string|max:' . self::MAX_STRING,
//            'custom_field' => 'nullable|string|max:' . self::MAX_STRING,
        ];

        return $rules;
    }
}


